package top.fangw.tenant.pojo.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import jakarta.validation.constraints.NotBlank;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import top.fangw.common.core.entity.BaseEntityWithOutName;

/**
 * <p>
 * 用途：用于管理系统中的租户信息
 * </p>
 *
 * @author fangw
 * @since 2024-01-16
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("g_tbl_tenant_info")
@Schema(name = "TenantInfo", description = "用途：用于管理系统中的租户信息")
public class TenantInfo extends BaseEntityWithOutName {


    @Schema(description = "租户名称用来展示的租户名称")
    @TableField("tenant_name")
    @NotBlank(message = "租户名称不能为空")
    private String tenantName;

    @Schema(description = "租户编号用于根据租户号创建数据库或数据表")
    @TableField("tenant_id")
    @NotBlank(message = "租户编号不能为空")
    private String tenantId;

    @Schema(description = "是否可删除0：可删除  1：不可删除")
    @TableField("is_deletable")
    private String isDeletable;

    @Schema(description = "数据源编号")
    @TableField("datasource_id")
    @NotBlank(message = "数据源编号不能为空")
    private String datasourceId;

    @Schema(description = "数据源类型0: 基于字段隔离 1:基于数据表隔离 2:基于数据库隔离")
    @TableField("datasource_type")
    private String datasourceType;

    @Schema(description = "套餐编号")
    @TableField("tenant_package_id")
    @NotBlank(message = "套餐编号不能为空")
    private String tenantPackageId;

    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @Schema(description = "租户生效开始时间")
    @TableField("start_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime startTime;

    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @Schema(description = "租户有效期结束时间")
    @TableField("end_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime endTime;

    @Schema(description = "公司名称")
    @TableField("company_name")
    private String companyName;

    @Schema(description = "联系人")
    @TableField("contact")
    private String contact;

    @Schema(description = "联系电话")
    @TableField("telephone")
    private String telephone;
}
